package com.linkwechat.wecom.service.impl;

import com.linkwechat.wecom.domain.WeworkKfCustomer;
import com.linkwechat.wecom.mapper.WeworkKfCustomerMapper;
import com.linkwechat.wecom.service.IWeworkKfCustomerService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.apache.commons.lang3.StringUtils;

import java.util.List;

/**
 * 企微客服咨询客户Service业务层处理
 *
 * @author ruoyi
 * @date 2022-03-11
 */
@Service
public class WeworkKfCustomerServiceImpl extends ServiceImpl<WeworkKfCustomerMapper, WeworkKfCustomer> implements IWeworkKfCustomerService {

    @Override
    public List<WeworkKfCustomer> queryList(WeworkKfCustomer weworkKfCustomer) {
        LambdaQueryWrapper<WeworkKfCustomer> lqw = Wrappers.lambdaQuery();
        if (weworkKfCustomer.getId() != null){
            lqw.eq(WeworkKfCustomer::getId , weworkKfCustomer.getId());
        }
        if (StringUtils.isNotBlank(weworkKfCustomer.getOpenKfid())){
            lqw.eq(WeworkKfCustomer::getOpenKfid , weworkKfCustomer.getOpenKfid());
        }
        if (StringUtils.isNotBlank(weworkKfCustomer.getExternalUserid())){
            lqw.eq(WeworkKfCustomer::getExternalUserid , weworkKfCustomer.getExternalUserid());
        }
        if (StringUtils.isNotBlank(weworkKfCustomer.getMobile())){
            lqw.eq(WeworkKfCustomer::getMobile , weworkKfCustomer.getMobile());
        }
        if (weworkKfCustomer.getStatus() != null){
            lqw.eq(WeworkKfCustomer::getStatus , weworkKfCustomer.getStatus());
        }
        if (weworkKfCustomer.getCurrentServicerId() != null){
            lqw.eq(WeworkKfCustomer::getCurrentServicerId , weworkKfCustomer.getCurrentServicerId());
        }

        return this.list(lqw);
    }
}
